Skip to content

solid_agent 0.2.0: tool persistence + enrichment, ToolCache, HasMemory, ModelPricing, AgentRun - #4

Merged
TonsOfFun merged 5 commits into
mainfrom
claude/analytics-api-key-encryption-9kwpsc
Aug 1, 2026
Merged

solid_agent 0.2.0: tool persistence + enrichment, ToolCache, HasMemory, ModelPricing, AgentRun#4
TonsOfFun merged 5 commits into
mainfrom
claude/analytics-api-key-encryption-9kwpsc

Conversation

@TonsOfFun

@TonsOfFun TonsOfFun commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

The 0.2.0 feature set — solid_agent persists and caches the full agent interaction stream out of the box, for any Rails app using activeagent:

  • Tool interaction persistenceHasContext persists every tool-result message from the response's message stack to the context via add_tool_message (deduped by tool_call_id), so conversations record the full agent ↔ tool/MCP exchange, not just the final assistant text. Contexts without add_tool_message are skipped, keeping it drop-in for existing apps.
  • Enrichment hook — executors that run tools server-side can override tool_invocations to supply their invocation records ({tool_call_id:, name:, arguments:, duration_ms:}); HasContext matches them to response tool messages by tool_call_id, else by position (Ollama's tool messages carry neither name nor id), so persisted rows carry arguments and timing. Enrichment keywords are only passed when the context's add_tool_message accepts them — models generated before this change keep working.
  • SolidAgent::ToolCache — caches tool/MCP/service results by (tool, normalized args) with a TTL, backed by Rails.cache (any read/write store can be injected). Error-shaped results ({ error: ... }) are never cached; replays are tagged cached: true.
  • SolidAgent::HasMemory — an agent-curated summary list the model reads/writes via save_memory/recall_memory function-calling tools. Memory is scoped to a subject record (memorable, scope) rather than the agent class, so agents operating on the same subject share it — a handoff channel with source_agent provenance and AgentMemory#to_prompt for instruction injection.
  • SolidAgent::ModelPricing — token counts → estimated USD (RubyLLM registry rates when available, static pattern-table fallback; mock models price free). The generated AgentGeneration#estimated_cost uses it.
  • AgentRun — durable run records installed by the generator: lifecycle status, append-only progress events (append_event), trace_id correlation, token/duration accounting, and SolidAgent::RunFingerprint instruction cohorts with deterministic codenames ("calm-heron").
  • README rewritten to document the full surface (seven concerns + ToolCache/ModelPricing/AgentManifest and the solid_agent:install generator).
  • Version bumped to 0.2.0 — consumers gate on the version to know whether HasContext persists tool details itself.

Test plan

  • test/solid_agent/tool_cache_test.rb, has_memory_test.rb, has_context_tool_messages_test.rb, model_pricing_test.rb, run_fingerprint_test.rb
  • Full gem suite: 220 runs, 511 assertions, 0 failures.
  • Consumed end-to-end by the activeagents platform (companion branch), whose suite was verified green against both the locked 0.1.1 gem and a local 0.2.0 override.

🤖 Generated with Claude Code

https://claude.ai/code/session_01B5PaDq3uaUWuA8UW4K7siP

claude added 2 commits July 29, 2026 19:46
Conversations persisted through HasContext only recorded the final
assistant message; the tool/MCP roundtrips in the response's message
stack were dropped, so downstream views (like the ActiveAgents
Interactions dashboard) couldn't show what an agent actually did.

- HasContext now persists each tool-result message to the context via
  add_tool_message (already part of the install generator's
  AgentContext), deduped by tool_call_id so shared message stacks in
  multi-turn conversations don't duplicate rows. Contexts without
  add_tool_message are skipped, keeping the change drop-in for
  existing apps.

- New SolidAgent::ToolCache caches tool/MCP/service results by
  (tool, normalized args) with a TTL, backed by Rails.cache out of
  the box and by any read/write store elsewhere. Error-shaped results
  ({ error: ... }) are never cached, and replayed hashes are tagged
  cached: true so callers can tell a replay from a fresh call.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B5PaDq3uaUWuA8UW4K7siP
Bakes a memory concern into solid_agent: agents persist a summary list
they decide when to read/write while interacting with tools, other
agents, and users.

- SolidAgent::HasMemory exposes save_memory/recall_memory as
  function-calling tool definitions plus matching instance methods, so
  a provider's tool calls route straight to persistent memory. The
  memory subject defaults to params[:memorable], falling back to the
  HasContext contextable.
- Memory is scoped to (memorable subject, scope) rather than the agent
  class, so any agent operating on the same subject shares it — a
  handoff channel between agents, with source_agent provenance on
  every entry and AgentMemory#to_prompt for instruction injection.
- The install generator now creates agent_memories /
  agent_memory_entries tables and AgentMemory/AgentMemoryEntry models
  implementing the duck-typed contract, so existing Rails apps get
  memory out of the box alongside contexts.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B5PaDq3uaUWuA8UW4K7siP
@superconductor-for-github

Copy link
Copy Markdown

Superconductor is workingView implementation


I'll get back to you soon!

claude added 3 commits August 1, 2026 15:39
- HasContext#persist_tool_messages_to_context now consults an overridable
  tool_invocations hook: executors that run tools server-side return
  invocation records ({tool_call_id:, name:, arguments:, duration_ms:})
  which are matched to response tool messages by tool_call_id, else by
  position (Ollama's tool messages carry neither name nor id). Persisted
  rows then carry the call's arguments and timing. Enrichment keywords
  are only passed when the context's add_tool_message accepts them, so
  models generated before this change keep working.
- Install template AgentContext#add_tool_message gains arguments:/
  duration_ms: (writes tool_arguments + metadata duration_ms), matching
  what the enrichment path passes.
- SolidAgent::ModelPricing: token counts -> estimated USD. RubyLLM
  registry rates when available, static pattern table fallback, blended
  default. Mock models price free (pattern ordered before real models so
  mock-gpt-4o-mini doesn't bill at gpt-4o rates). The template's
  AgentGeneration#estimated_cost uses it when no explicit rates given.
- README: document all seven concerns + ToolCache/ModelPricing/
  AgentManifest and the solid_agent:install generator (it previously
  described three concerns and omitted install entirely).

215 runs, 496 assertions, 0 failures.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B5PaDq3uaUWuA8UW4K7siP
HasMemory, ToolCache, ModelPricing, and enriched tool persistence are a
minor-version feature set — and consumers gate on the version to know
whether HasContext persists tool details itself.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B5PaDq3uaUWuA8UW4K7siP
The install generator now ships an agent_runs table + AgentRun model —
the platform-proven shape for run orchestration: lifecycle status
(pending/running/complete/failed/cancelled with start!/complete!/fail!/
cancel!), token + duration accounting, trace_id correlation with
contexts/generations/telemetry, and an append-only progress-event
stream (append_event: eid-paired started/done/error events, byte-capped
detail, update_column so the run's own thread appends safely).

SolidAgent::RunFingerprint carries the cohort logic: 8-char instruction
digests and deterministic adjective-noun codenames ("calm-heron") so
configuration cohorts read as names instead of hex.

220 runs, 0 failures.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B5PaDq3uaUWuA8UW4K7siP
@TonsOfFun TonsOfFun changed the title Tool interaction persistence, ToolCache, and HasMemory solid_agent 0.2.0: tool persistence + enrichment, ToolCache, HasMemory, ModelPricing, AgentRun Aug 1, 2026
@TonsOfFun
TonsOfFun merged commit 866f31f into main Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants